package hamsterwrench;

/*From const.bi file:
 * OHRRPGCE GAME - shared constants
 * (C) Copyright 1997-2005 James Paige and Hamster Republic Productions
 * Please read LICENSE.txt for GPL License details and disclaimer of liability
 * See README.txt for code docs and apologies for crappyness of this code ;)
 *
 * Java port 2013 Matthias Lamers
 */

public final class OHRRPGCE {
	/*This class is just a list of constants that the OHR source code uses. Mostly lifted wholesale from const.bi*/
	public static final int CURRENT_RPG_VERSION = 19;
	// It is a good idea to increment this number each time a major feature
	// has been added, if opening a new game in an old editor would cause data-loss
	// Don't be afraid to increment this. Backcompat warnings are a good thing!
	//--version history
	// 7 - ypsiliform wip added > 36 NPC defs (and many other features)
	// 8 - ypsiliform wip added extended chaining data (and many other features)
	// 9 - ypsiliform wip added text box sound effects
	// 10 - ypsiliform wip added attack-based enemy transmogrification
	// 11 - zenzizenzic wip added variable record size and record number .N## lumps
	// 12 - zenzizenzic wip increased .N## record size
	// 13 - zenzizenzic wip changed password format to PW4, older versions have broken genPassVersion handling
	// 14 - zenzizenzic wip made .DT0 binsize-sized
	// 15 - zenzizenzic wip made .DT1 binsize-sized, and added binsize.bin, fixbits.bit safeguards
	// 16 - zenzizenzic wip made .ITM binsize-sized
	// 17 - alectormancy wip increase global limit from 4095 to 16383
	// 18 - beelzebufo turn-based support
	// 19 - beelzebufo replaced .DT0 with heroes.reld

	public static final int CURRENT_RSAV_VERSION = 3;
	// Increment this number any time that loading and resaving a game in either
	// new or old versions of Game leads to data-loss, or major new features are
	// added.
	// 1 - zenzizenzic wip removed nativehbits related nodes
	// 2 - alectormancy wip increased global limit from 4095 to 16383
	// 3 - stopped writing obsolete battle_menus node

//	//---GENERAL GAME DATA (.GEN) constants---
//	public static final int genMaxMap = 0;             //max map ID
//	public static final int genTitle = 1;              //title screen backdrop
//	public static final int genTitleMus = 2;           //title music
//	public static final int genVictMus  = 3;           //victory music
//	public static final int genBatMus = 4;             //default battle music
//	public static final int genPassVersion = 5;        //passcode format number
//	public static final int genPW3Rot = 6;             //old (third style) passcode rotator
//	//7-25: first style or third style encoded passcode
//	public static final int genMaxHeroPic = 26;        //max hero graphic number in .PT0
//	public static final int genMaxEnemy1Pic = 27;      //max small enemy graphic number in .PT1
//	public static final int genMaxEnemy2Pic = 28;      //max medium enemy graphic number in .PT2
//	public static final int genMaxEnemy3Pic = 29;      //max large enemy graphic number in .PT3
//	public static final int genMaxNPCPic = 30;         //max npc graphic number in .PT4
//	public static final int genMaxWeaponPic = 31;      //max weapon graphic number in .PT5
//	public static final int genMaxAttackPic = 32;      //max attack graphic number in .PT6
//	public static final int genMaxTile = 33;           //max tileset number in .TIL
//	public static final int genMaxAttack = 34;         //max attack definition number in .DT6
//	public static final int genMaxHero = 35;           //max hero definition number in .DT0
//	public static final int genMaxEnemy = 36;          //max enemy definition number in .DT1
//	public static final int genMaxFormation = 37;      //max formation number in .FOR
//	public static final int genMaxPal = 38;            //max palette number in .PAL
//	public static final int genMaxTextbox = 39;        //max text box number in .SAY
//	public static final int genNumPlotscripts = 40;    //number of scripts of any kind (number of records in PLOTSCR.LST)
//	public static final int genNewGameScript = 41;     //id of new-game plotscript
//	public static final int genGameoverScript = 42;    //id of game-over plotscript
//	public static final int genMaxRegularScript = 43;  //id of highest numbered non-autonumbered plotscript
//	public static final int genSuspendBits = 44;       //suspend stuff bits
//	public static final int genCamera = 45;            //camera mode
//	public static final int genCamArg1 = 46;           //cameraarg1
//	public static final int genCamArg2 = 47;           //cameraarg2
//	public static final int genCamArg3 = 48;           //cameraarg3
//	public static final int genCamArg4 = 49;           //cameraarg4
//	public static final int genScrBackdrop = 50;       //currently displaying script backdrop in .MXS + 1, 0 for none
//	public static final int genDays = 51;              //days of play
//	public static final int genHours = 52;             //hours of play
//	public static final int genMinutes = 53;           //minutes of play
//	public static final int genSeconds = 54;           //seconds of play
//	public static final int genMaxVehicle = 55;        //max vehicle type number in .VEH
//	public static final int genMaxTagname = 56;        //last named tag
//	public static final int genLoadGameScript = 57;    //load-game script
//	public static final int genTextboxBackdrop = 58;   //currently displaying text box backdrop in .MXS + 1, 0 for none
//	public static final int genEnemyDissolve = 59;     //Default dissolve animation for dying enemies
//	public static final int genJoy = 60;               //enable/disable joystick
//	public static final int genPoison = 61;            //poison status indicator char
//	public static final int genStun = 62;              //Stun status indicator char
//	public static final int genDamageCap = 63;         //Damage cap
//	public static final int genMute = 64;              //Mute status indicator char
//	public static final int genStatCap = 65;           //Stat caps (genStatCap + stat) (65-76)
//	public static final int genMaxSFX = 77;            //last song number
//	public static final int genMasterPal = 78;         //master palette number
//	public static final int genMaxMasterPal = 79;      //max master palette number
//	public static final int genMaxMenu = 80;           //max menu def in MENUS.BIN
//	public static final int genMaxMenuItem = 81;       //max menu item def in MENUITEM.BIN
//	public static final int genMaxItem = 82;           //max item in .ITM
//	public static final int genMaxBoxBorder = 83;      //max box border number in .PT7
//	public static final int genMaxPortrait = 84;       //max portrait graphic number in .PT8
//	public static final int genMaxInventory = 85;      //max available inventory slot (0 means use inventoryMax)
//	public static final int genErrorLevel = 86;        //value to set err_suppress_lvl to, if nonzero
//	public static final int genLevelCap = 87;          //Default maximum level (0 to 99)
//	public static final int genEquipMergeFormula = 88; //Formula to use to calculate effective hero elemental resists
//	public static final int genNumElements = 89;       //Number of elements used
//	public static final int genUnlockedReserveXP = 90; //% experience gained by unlocked reserve heroes
//	public static final int genLockedReserveXP = 91;   //% experience gained by locked reserve heroes
//	public static final int genPW4Hash = 92;           //new (4th style) password hash
//	public static final int genPW2Offset = 93;         //old-old password offset
//	public static final int genPW2Length = 94;         //old-old password length
//	public static final int genVersion = 95;           //RPG file format version (see CURRENT_RPG_VERSION above for latest)
//	public static final int genStartMoney = 96;        //starting money
//	public static final int genMaxShop = 97;           //last shop in .SHO
//	public static final int genPW1Offset = 98;         //old-old-old password offset
//	public static final int genPW1Length = 99;         //old-old-old password length
//	public static final int genNumBackdrops = 100;     //number of screens in .MXS
//	public static final int genBits = 101;             //general bitsets
//	public static final int genStartX = 102;           //starting X
//	public static final int genStartY = 103;           //starting Y
//	public static final int genStartMap = 104;         //starting Map
//	public static final int genOneTimeNPC = 105;       //one-time-NPC indexer
//	public static final int genDefaultDeathSFX = 171;  //default enemy death sound effect
//	public static final int genMaxSong = 172;          //last song number
//	public static final int genAcceptSFX = 173;        //menu interface
//	public static final int genCancelSFX = 174;        // "       "
//	public static final int genCursorSFX = 175;        // "       "
//	public static final int genTextboxLine = 176;      //Text box 'click'
//	public static final int genBits2 = 177;            //More general bitsets
//	public static final int genBits3 = 178;            //More general bitsets
//	public static final int genItemLearnSFX = 179;     //learn spell oob item
//	public static final int genCantLearnSFX = 180;     //hero couldn't learn spell from item
//	public static final int genBuySFX = 181;           //buy item from shop
//	public static final int genHireSFX = 182;          //hire from shop
//	public static final int genSellSFX = 183;          //sell item to shop
//	public static final int genCantBuySFX = 184;       //can't afford item/hire
//	public static final int genCantSellSFX = 185;      //unsellable item
//	public static final int genDamageDisplayTicks = 186; //number of ticks that battle damage displays
//	public static final int genDamageDisplayRise = 187; //number of pixels that damage display rises
//	public static final int genHeroWeakHP = 188;       //%HP for heroes to use Weak state
//	public static final int genEnemyWeakHP = 189;      //%HP for enemies to use Desperation AI
//	public static final int genAutosortScheme = 190;   //Method used to autosort inventory
//	public static final int genMaxLevel = 191;         //Maximum level (not to be confused with changeable genLevelCap)
//	public static final int genBattleMode = 192;       //Battle mode 0=Active-time, 1=Turn-based
//	public static final int genResolutionX = 194;       //Screen resolution (unzoomed). 0 for default
//	public static final int genResolutionY = 195;       // "
//	public static final int genEscMenuScript = 196;     //id of plotscript called instead of the default menu
	//196 to 198 unused
	//199 to 359 used to be the scattertable for PW2, now zeroed out
	//360 to 499 unused

	//---Built in stats
	public static final int statHP = 0;
	public static final int statMP = 1;
	public static final int statAtk = 2;
	public static final int statAim = 3;
	public static final int statDef = 4;
	public static final int statDodge = 5;
	public static final int statMagic = 6;
	public static final int statWill = 7;
	public static final int statSpeed = 8;
	public static final int statCtr = 9;
	public static final int statFocus = 10;
	public static final int statHitX = 11;
	public static final int statUser = 12;              //Additional user defined stats, if any, start here
	
	public static final int statLast = 11;				//Index of last actually defined stat.

	//Start addendum - ML
    public static final int AT_LV_0 = 0;
    public static final int AT_LV_99 = 1;
    //end addendum
	
	//---Format fix bits
	public static final int fixAttackitems = 0;         //zero out attack data for item cost (ammunition)
	public static final int fixWeapPoints  = 1;         //add defaults for weapon points
	public static final int fixStunCancelTarg = 2;      //turn on cancel target bitset for old stun attacks
	public static final int fixDefaultDissolve = 3;     //Initialized genEnemyDissolve to default in GEN
	public static final int fixDefaultDissolveEnemy = 4;//Initialized Enemy dissolves to default in DT1
	public static final int fixPushNPCBugCompat = 5;    //Turned on the Simulate pushable NPC obstruction bug bitset
	public static final int fixDefaultMaxItem = 6;      //Stored default max item id in GEN
	public static final int fixBlankDoorLinks = 7;      //Marked redundant blank doorlinks as unused
	public static final int fixShopSounds = 8;          //Set genItemLearnSFX..genCantSellSFX to defaults
	public static final int fixExtendedNPCs = 9;        //Deleted or initialised garbage NPC data in IDs 36 to 99
	public static final int fixHeroPortrait = 10;       //Initialize hero portrait data
	public static final int fixTextBoxPortrait = 11;    //Initialize text box portrait data
	public static final int fixNPCLocationFormat = 12;  //FIXME: not implemented ... can't remember....
	public static final int fixInitDamageDisplay = 13;  //Initialize damage display time and distance
	public static final int fixDefaultLevelCap = 14;    //Set level cap to 99
	public static final int fixHeroElementals = 15;     //Set the hero elemental data from the old weak/strong/absorb bits
	public static final int fixOldElementalFailBit = 16;//Turned on the 'Simulate old fail vs. element resist bit' bitset
	public static final int fixAttackElementFails = 17; //Initialized all 64 attack elemental fail conditions
	public static final int fixEnemyElementals = 18;    //Set enemy elemental resists from old weak/strong/absorb/enemytype bits
	public static final int fixItemElementals = 19;     //Set equipment elemental resists from old weak/strong/absorb bits
	public static final int fixNumElements = 20;        //Set genNumElements to 16
	public static final int fixRemoveDamageMP = 21;      //Removed the obsolete Damage MP attack bit
	public static final int fixDefaultMaxLevel = 22;    //Set max level to 99 (not to be confused with level cap)
	public static final int fixUNUSED23 = 23;           //Don't use this bit for anything. It was wasted in a plan that changed

	public static final int sizefixbits = 23; // *** Update this when adding fix bits ***

	//---Sizes (replaceable with variables when suitable)
	public static final int max_npc_defs = 500; //max number of NPC IDs definable in Custom
	public static final int maxMaxItems = 32000; //max number of items
	public static final int maxMaxHero = 59; //This is the max value possible for gen(genMaxHero) //FIXME: not used everywhere
	public static final int inventoryMax = 599; //last inventory slot num (divisible by 3 when you count the zero)
	public static final int maplayerMax = 7; //The limit on the highest numbered map layer
	public static final int mapTilesMax = 100000; //Maximum map size, in tiles (note also a limit of 32768 tiles wide or high)
	public static final int dissolveTypeMax = 10; //Highest numbered frame dissolve effect
	public static final int maxElements = 64; //Maximum selectable number of elements
	public static final int tempZone = 10000; //ID (and up) to use for temporary zones
	public static final long maxMapHistoryMem = 1000000; //In number of MapEditUndoTiles (8 bytes)
	
	public static final long scriptmemMax = 10000000; //in 4-byte ints
	public static final int scriptTableSize = 512;  //hash table size, power of 2 please
	public static final int maxLoadedScripts = 32768;
//	public static final long scriptmemMax = 65536; //in 4-byte ints (256kb)
//	public static final int scriptTableSize = 256;  //hash table size, power of 2 please
//	public static final int maxLoadedScripts = 360;
	public static final double scriptCheckDelay = 1.1;
	public static final double scriptCheckInterval = 0.1;

	//--- Binary files in BINSIZE.BIN for getbinsize()
	public static final int binATTACK = 0;
	public static final int binSTF = 1;
	public static final int binSONGDATA = 2;
	public static final int binSFXDATA = 3;
	public static final int binMAP = 4;
	public static final int binMENUS = 5;
	public static final int binMENUITEM = 6;
	public static final int binUICOLORS = 7;
	public static final int binSAY = 8;
	public static final int binN = 9;
	public static final int binDT0 = 10;
	public static final int binDT1 = 11;
	public static final int binITM = 12;

	public static final int sizebinsize = 12; // *** Update this when adding binsize records ***
	
	//addendum ML
	public static final char[] RELOAD_HEADER = {'R', 'E', 'L', 'D'};
	public static final int RELOAD_CURRENT_VERSION = 1;
	public static final int RELOAD_CURRENT_HEADER_SIZE = 13;
	//end ML
	
	//--- Misc constants
	public enum Direction{
		dirUp,
		dirRight,
		dirDown,
		dirLeft
	}
	
	//Game properties
	public enum GameErrorHandling{
		DEFAULT, RESERVED, SHOW_ALL_WARNINGS, SUPPRESS_SOME_WARNINGS, SUPPRESS_WEAK_TYPE_CHECKING, DONT_SHOW_NEW_ERRORS, 
		SHOW_ONLY_CORRUPTION_OR_INTERPRETER_ERRORS
	}
	
	public enum ScriptErrorType{
		INFORMATION, WARNING, SUSPICIOUS_OPERATION, BOUNDS, BAD_OPERATION, ERROR, ENGINE_BUG
	}
	
	public enum ErrorLevel{
		INFO, DEBUG, ERROR, BUG, PROMPT, PROMPT_BUG, FATAL, FATAL_BUG, TERMINATE
	}
	
	public enum GameEquipmentElementMath{
		STUPID, MULTIPLICITIVE, ADDITIVE
	}
	
	public enum GameInventoryAutosortMethod{
		BY_TYPE, BY_USABILITY, APLHABETICALLY, BY_ID, JUST_DEFRAG
	}
		
	//NPC properties
	public enum NPCMoveType{
		STAND_STILL, WANDER, PACE, RIGHT_TURNS, LEFT_TURNS, RANDOM_TURNS, CHASE_PLAYER, AVOID_PLAYER, WALK_IN_PLACE 
	}
	
	public enum NPCSpeed{
		ZERO, ONE, TWO, TEN, FOUR, FIVE
	}
	
	public enum NPCActivationBehavior{
		CHANGE_DIRECTION, FACE_PLAYER, DONT_FACE_PLAYER
	}
	
	public enum NPCPushability{
		OFF, FULL, HORIZONTAL, VERTICAL, UP_ONLY, RIGHT_ONLY, DOWN_ONLY, LEFT_ONLY
	}
	
	public enum NPCActivationMethod{
		USE, TOUCH, STEP_ON
	}
	
	//Hero properties
	public enum HeroSpells{
		MP_BASED, FF1_STYLE, RANDOM, RESERVED
	}
	
	//Enemy properties
	public enum EnemyPictureSize{
		SMALL, MEDIUM, BIG
	}
	
	public enum	EnemyDeathAnimation{
		DEFAULT, RANDOM_PIXELS, CROSSFADE, DIAGONAL_VANISH, SINK_INTO_GROUND, MELT, VAPORIZE, PHASE_OUT, SQUEEZE, SHRINK, FLICKER
	}
	
	public enum EnemyThievability{
		NEVER, ONCE, MANY
	}
	
	//Item properties
	public enum ItemEquippableAs{
		NEVER_EQUIPPED, WEAPON, SLOT_1, SLOT_2, SLOT_3, SLOT_4
	}
	
	public enum ItemConsumability{
		UNLIMITED_USE, CONSUMED_BY_USE, CANT_SELL_OR_DROP
	}
	
	//Text box properties
	public enum TextBoxPortraitType{
		NONE, FIXED, HERO_BY_CATERPILLAR, HERO_BY_PARTY_SLOT
	}
	
	//Menu properties
	//TODO add the MENUITEM.BIN enums
	public enum MenuItemType{
		LABEL, SPECIAL_SCREEN, GO_TO_MENU, SHOW_TEXT_BOX, RUN_SCRIPT
	}
	
	public enum MenuLabelSubtype{
		SELECTABLE, NOT_SELECTABLE
	}
	
	//Vehicle properties
	//TODO add the .VEH enums
	
	//map passability bits
	public static final int passNorthWall = 1;
	public static final int passEastWall = 2;
	public static final int passSouthWall = 4;
	public static final int passWestWall = 8;
	public static final int passVehA = 16;
	public static final int passVehB = 32;
	public static final int passHarm = 64;
	public static final int passObsoleteOverhead = 128;

	//--- Constants for carray() 
	public static final int ccUp = 0;
	public static final int ccDown = 1;
	public static final int ccLeft = 2;
	public static final int ccRight = 3;
	public static final int ccUse = 4;
	public static final int ccMenu = 5;
	public static final int ccRun = 6;
}
